﻿using System;
using ConsoleAppE1;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace OrderServiceUnitTest
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
        }

        /// <summary>
        /// AddOrder测试用例-控制台
        /// </summary>
        [TestMethod]
        public void TestAddOrder()
        {
            AllOrder a = new AllOrder();
            a.addOrder();
        }

        /// <summary>
        /// addOrder测试用例
        /// </summary>
        [TestMethod]
        public void TestAddOrder2()
        {
            Order order = new Order(1, "用户1", "2022/3/30");
            order.orderItem.Add(new OrderItem()
            {
                Name = "商品1",
                Number = 2,
                Price = 10.5
            });
            order.orderItem.Add(new OrderItem()
            {
                Name = "商品2",
                Number = 3,
                Price = 12.5
            });
            AllOrder a = new AllOrder();
            a.addOrder(order);
        }

        /// <summary>
        /// removeOrder测试用例
        /// </summary>
        [TestMethod]
        public void TestRemoveOrder()
        {
            int id = 1; 

            Order order = new Order(id, "用户1", "2022/3/30");
            order.orderItem.Add(new OrderItem()
            {
                Name = "商品1",
                Number = 2,
                Price = 10.5
            });
            order.orderItem.Add(new OrderItem()
            {
                Name = "商品2",
                Number = 3,
                Price = 12.5
            });
            AllOrder a = new AllOrder();
            a.addOrder(order);
            //删除
            a.order.RemoveAt(id);
        }

        /// <summary>
        /// removeOrder测试用例
        /// </summary>
        [TestMethod]
        public void TestSearchOrder()
        {
            int id = 1;

            Order order = new Order(id, "用户1", "2022/3/30");
            order.orderItem.Add(new OrderItem()
            {
                Name = "商品1",
                Number = 2,
                Price = 10.5
            });
            order.orderItem.Add(new OrderItem()
            {
                Name = "商品2",
                Number = 3,
                Price = 12.5
            });
            AllOrder a = new AllOrder();
            a.addOrder(order);

 
            a.searchOrder(id);
        }

        /// <summary>
        /// exprot测试用例
        /// </summary>
        [TestMethod]
        public void TestExprot()
        {
            AllOrder a = new AllOrder();
            a.export();
        }

        /// <summary>
        /// import测试用例
        /// </summary>
        [TestMethod]
        public void TestImport()
        {
            AllOrder a = new AllOrder();
            a.import();
        }
    }
}
